import api from '@/libs/request'
import { IntraCityDistributionConfig } from './types'

/**
 * 获取平台类目列表
 */
export const doGetPlatformCategory = (params: any) => {
    return api.get('gruul-mall-addon-platform/platform/shop/signing/category/choosable/list', params)
}
/**
 * 获取分类列表
 */
export const doGetCategory = (params: any) => {
    return api.get('gruul-mall-goods/goods/product/category', params)
}
/**
 * 获取供应商列表
 * @param {any} params
 */
export const doGetSupList = (params: any) => {
    return api.get('gruul-mall-goods/manager/supplier/list', params)
}
/**
 * 获取属性列表
 * @param {any} params
 */
export const getAttsList = (params: any) => {
    return api.get('gruul-mall-goods/manager/attribute/template/list', params)
}
/**
 *获取品牌列表
 */
export const getBrandList = (data: any) => {
    return api.get('gruul-mall-search/search/brand/brandInfo', data)
}
/**
 * 获取商品列表
 * @param {any} params
 */
export const doGetCommodity = (params: any) => {
    return api.get('gruul-mall-goods/manager/product/list', params)
}
/**
 * 发布商品
 * @param {any} data
 */
export const doReleaseGood = (data: any) => {
    return api.post('gruul-mall-goods/manager/product/issue', data)
}

/**
 * 获取所有展示分类
 * @param data
 */
export const getAllCategory = (data: any) => {
    return api.get('/goods-open/manager/show/category/get/all', data)
}
/**
 * 获取展示分类列表
 * @param data
 */
export const getProList = (data: any) => {
    return api.get('/goods-open/manager/product/list', data)
}

/**
 * 获取select类目选择项
 * @param {string} level
 * @param {string} parentId
 */
export const doGetCategoryLevel = (level: string | number, parentId: string | number) => {
    return api.get(`gruul-mall-goods/goods/product/category/by/parent/${parentId}`, {
        level: `LEVEL_${Number(level) + 1}`,
        size: 1000,
    })
}
/**
 * 新增分类
 * @param {any} data
 */
export const doNewCategory = (data: any) => {
    return api.post('gruul-mall-goods/goods/product/category', data)
}

/**
 * 更新类目
 * @param {any} data
 */
export const doUpdateCategory = (id: string, data: any) => {
    return api.put(`gruul-mall-goods/goods/product/category/${id}`, data)
}
/**
 * 删除类目
 * @param {string} id
 */
export const doDelCategory = (id: string) => {
    return api.delete(`gruul-mall-goods/goods/product/category/${id}`)
}

/**
 * 属性模板删除
 * @param {string} id
 */
export const delAttr = (ids: string) => {
    return api.delete(`gruul-mall-goods/manager/attribute/template/delete/${ids}`)
}
/**
 * 属性模板子属性删除
 * @param {string} id
 */
export const delAttrSon = (id: string) => {
    return api.delete(`gruul-mall-goods/manager/attribute/template/delete/child/${id}`)
}
/**
 * 新增属性模板
 * @param {*}
 */
export const addAttrList = (data: any) => {
    return api.post(`gruul-mall-goods/manager/attribute/template/save`, data)
}
/**
 * 更新属性模板
 * @param {any} data
 */
export const updateAttrList = (data: any) => {
    return api.put('gruul-mall-goods/manager/attribute/template/update', data)
}

/**
 * 删除供应商
 * @param {string} ids
 */
export const doDelSupplier = (ids: string) => {
    return api.delete(`gruul-mall-goods/manager/supplier/delete/${ids}`)
}
/**
 * 新增供应商
 */
export const doSaveSupplier = (data: any) => {
    return api.post('gruul-mall-goods/manager/supplier/save', data)
}
/**
 * 修改供应商
 * @param {any} data
 */
export const doUpdateSupplier = (data: any) => {
    return api.put('gruul-mall-goods/manager/supplier/update', data)
}
/**
 * 审核供应商
 * @param {any} data
 */
export const doVerifySupplier = (data: any) => {
    return api.put('gruul-mall-goods/manager/supplier/check', data)
}

/**
 * 编辑商品
 * @param {any} data
 */
export const doUpdateCommodity = (data: any) => {
    return api.put('gruul-mall-goods/manager/product/update', data)
}
/**
 * 更新商品状态
 * @param {string} ids
 * @param {string} status
 */
export const doUpdateSellStatus = (keys: { shopId: string; productId: string }[], status: string) => {
    return api.put(`gruul-mall-goods/manager/product/updateStatus/${status}`, {
        keys,
    })
}
/**
 * 删除商品
 * @param {string} ids
 */
export const doDeleteCommodity = (ids: any) => {
    return api.delete(`gruul-mall-goods/manager/product/delete/${ids}`)
}
/**
 * 获取单个商品信息
 * @param {string} id
 */
export const doGetSingleCommodity = (id: any, shopId: any) => {
    return api.get(`gruul-mall-goods/manager/product/get/${shopId}/${id}`)
}
/**
 * 设置限购
 * @param {any} data
 */
export const doSetPurchase = (productId: string, data: any) => {
    return api.post(`/gruul-mall-storage/storage/product/${productId}/limit`, data)
}
export const doSetInventory = (productId: string, data: any) => {
    return api.post(`gruul-mall-storage/storage/product/${productId}/stock`, data)
}
/**
 * 查询商品规格组与sku列表
 */
export const doGetCommoditySku = (shopId: string, productId: any) => {
    return api.get(`gruul-mall-storage/storage/shop/${shopId}/product/${productId}`)
}
/**
 * 查询商品库存与限购
 */
export const doGetProductPurchasing = (productId: string) => {
    return api.get(`gruul-mall-storage/storage/product/${productId}`)
}

/**
 * 查询一级分类和分类下的商品数量
 */
export const doGetHighestCategoryLevel = (params) => {
    return api.get(`gruul-mall-goods/goods/product/category/categoryLevel1WithProductNum`, params)
}

/**
 * 通用检索商品接口
 */
export const doGetComRetrieve = (data) => {
    return api.post('gruul-mall-search/search/product', data)
}
/**
 * 商品一键复制
 * 商品一键复制
 * @param {string} id
 */
export const doGetCopyGoods = (params) => {
    return api.get(`gruul-mall-goods/api/copy/goods/detail`, params)
}
/**
 * 获取同城配送信息
 * @param data
 */
export const getIntraCityInfo = () => {
    return api.post<IntraCityDistributionConfig>('addon-ic/ic/shop/config/get')
}
